import { request } from '@pkg/request/src';

export enum Api {
  page = '/goods/page',
  list = '/goods/list',
  get = '/goods/get',
  add = '/goods/save',
  update = '/goods/update',
  remove = '/goods/remove',
  setIsShelf = '/goods/setIsShelf',
  setIsHomeRecommend = '/goods/setIsHomeRecommend',
  setIsMallRecommend = '/goods/setIsMallRecommend',
  setIsShowShop = '/goods/setIsShowShop',
  querySetWechat = '/goods/querySetWechat',
  setWechat = '/goods/setWechat',
}

export const page = (params) =>
  request.get(
    { url: Api.page, params: params },
    {
      errorMessageMode: 'none',
      successMessageMode: 'none',
    },
  );

export const goodsList = (params) =>
  request.get(
    {
      url: Api.list,
      params: params,
    },
    { errorMessageMode: 'none', successMessageMode: 'none' },
  );

export const getGoodsDetail = (params) =>
  request.get(
    {
      url: Api.get,
      params: params,
    },
    { errorMessageMode: 'none', successMessageMode: 'none' },
  );

export const add = (params) =>
  request.post(
    {
      url: Api.add,
      params: params,
    },
    { errorMessageMode: 'none' },
  );

export const update = (params) =>
  request.post(
    {
      url: Api.update,
      params: params,
    },
    { errorMessageMode: 'none' },
  );

export const remove = (ids: string) =>
  request.post(
    {
      url: Api.remove,
      params: { ids: ids },
    },
    { errorMessageMode: 'message' },
  );

export const setIsShelf = (goodsId, isShelf) =>
  request.post(
    {
      url: Api.setIsShelf,
      params: { goodsId, isShelf },
    },
    { errorMessageMode: 'message' },
  );

export const setIsHomeRecommend = (goodsId, isHomeRecommend) =>
  request.post(
    {
      url: Api.setIsHomeRecommend,
      params: { goodsId, isHomeRecommend },
    },
    { errorMessageMode: 'none' },
  );

export const setIsMallRecommend = (goodsId, isMallRecommend) =>
  request.post(
    {
      url: Api.setIsMallRecommend,
      params: { goodsId, isMallRecommend },
    },
    { errorMessageMode: 'none' },
  );

export const setIsShowShop = (goodsId, isShowShop) =>
  request.post(
    {
      url: Api.setIsShowShop,
      params: { goodsId, isShowShop },
    },
    { errorMessageMode: 'none' },
  );

export const querySetWechat = (params) =>
  request.get(
    {
      url: Api.querySetWechat,
      params: params,
    },
    { errorMessageMode: 'none' },
  );

export const setWechat = (params) =>
  request.post(
    {
      url: Api.setWechat,
      params: params,
    },
    { errorMessageMode: 'none' },
  );
